﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PersonEvents
{
    class Person
    {
        private string firstName;
        private string lastName;
        private string gender;
        private DateTime birthdate;

        public event FirstNameChangedEventHandler FirstNameChanged;
        public event PropertyChangedEventHandler propertyChanged;

        public Person(string firstName, string lastName, string gender, DateTime birthdate)
        {
            this.firstName = firstName;
            this.lastName = lastName;
            this.gender = gender;
            this.birthdate = birthdate;
        }

        protected void OnPropertyChanged(string propertyName, object oldValue, object newValue)
        {
            if (propertyChanged != null)
            {
                PropertyChangedEventArgs args = new PropertyChangedEventArgs(propertyName, oldValue, newValue);
                propertyChanged(this, args);
            }
        }

        protected void OnFirstNameChanged(string oldFirstName, string newFirstName)
        {
            if (FirstNameChanged != null)
            {
                FirstNameChangedEventArgs args = new FirstNameChangedEventArgs(oldFirstName, newFirstName);
                FirstNameChanged(this, args);
            }
        }

        public string FirstName
        {
            get
            {
                return firstName;
            }
            set
            {
                OnPropertyChanged("First Name", firstName, value);
                firstName = value;
            }
        }

        public string LastName
        {
            get
            {
                return lastName;
            }
            set
            {
                OnPropertyChanged("Last Name", lastName, value);
                lastName = value;
            }
        }

        public string Gender
        {
            get
            {
                return gender;
            }
            set
            {
                OnPropertyChanged("Pol", gender, value);
                gender = value;
            }
        }

        public DateTime Birthdate
        {
            get
            {
                return birthdate;
            }
            set
            {
                OnPropertyChanged("Data na rajdane", birthdate, value);
                birthdate = value;
            }
        }
    }
}
